<template>
	<view class="rank-page" :class="[current == 0 ? 'rank1' :'rank2']">
		<view class="container">
			<!-- 		<u-navbar title="mikua" :autoBack="true" :placeholder="true">
			
		</u-navbar> -->

			<view class="phb-logo">
				<view class="top_title">
					米夸商城
				</view>
				<view class="top_btn">
					推荐榜
				</view>
				<view class="rankimg-box">
					<image src="../../static/images/other/rank-left.png" class="rankleft-img" mode=""></image>
					<image src="../../static/images/other/rank-right.png" class="rankright-img" mode=""></image>
				</view>
			</view>

			<view class="discribe">
				{{catmessage.discribe}}
			</view>
			<u-tabs :list="list" :is-scroll="false" :current="current" @change="change" :activeStyle="{
			fontSize:'28rpx',
			color:'#fff'
		}" lineColor="#fff" :inactiveStyle="{
			fontSize:'28rpx',
			color:'#fff'
		}" lineWidth="60"></u-tabs>

			<view class="items">
				<view class="item" v-for="(item,index) in cat" :key="item.id" @click="goto(item.id)">
					<view class="number">{{index+1}}</view>
					<view class="btn">
						<view class="iconfont icon-xiangyou1">

						</view>
						<!-- <img src="/static/images/index/right-jiantou1.png" alt="" class="right" style="width: 30rpx;height: 30rpx;"> -->
					</view>
					<view class="left">
						<img :src="item.thum_image" alt="">
					</view>
					<view class="right">
						<view class="right-name">{{item.name}}</view>
						<view style="color: #100f0f5e;font-size: 24rpx;">
							{{item.cont1}}
						</view>
						<view class="right-price">
							￥{{item.price}} 起
						</view>
					</view>
				</view>


			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				list: [{
					name: '自行车畅销榜',
					id: 2
				}, {
					name: '周边热销榜',
					id: 3
				}],
				current: 0,
				cat: [],
				catmessage: {},
				bgColor: '#333d60',
			}
		},
		async onLoad() {
			let cate = await this.$api.getgoodcate({
				status: '2'
			})
			this.cat = cate.data.goods.data
			this.catmessage = cate.data.category
		},
		methods: {
			// 跳转商品详情页面
			goto(id) {
				uni.navigateTo({
					url: '/subPages/goodDetails/goodDetails?id=' + id
				})
			},
			// 获取推荐榜
			async getcat(id) {
				let cate = await this.$api.getgoodcate({
					status: id
				})
				this.cat = cate.data.goods.data
				this.catmessage = cate.data.category
			},
			// 推荐榜切换
			change(v) {
				this.getcat(v.id);
				console.log(v);
				this.current = v.index;
			}
		}
	}
</script>

<style lang="scss">
	.items {
		padding-top: 30rpx;
		padding: 30rpx 20rpx 0;



		.btn {
			right: 30rpx;
			bottom: 30rpx;
			position: absolute;
			width: 36rpx;
			height: 36rpx;
			background-color: #295be3;
			border-radius: 50%;
			text-align: center;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.item:nth-child(1) {
			.number {
				background-color: #fad154;
			}
		}

		.item:nth-child(2) {
			.number {
				background-color: #cbd2d8;
			}
		}

		.item:nth-child(3) {
			.number {
				background-color: #e6af77;
			}
		}

		.item {
			margin-top: 20rpx;
			background-color: #fff;
			border-radius: 10rpx;
			display: flex;
			position: relative;

			.number {
				width: 50rpx;
				height: 50rpx;
				background-color: #90908e;
				font-size: 30rpx;
				font-weight: 900;
				color: #fff;
				position: absolute;
				border-top-left-radius: 10rpx;
				border-bottom-right-radius: 10rpx;
				line-height: 50rpx;
				text-align: center;
			}



			.left {
				img {
					display: block;
					border-radius: 10rpx;
					width: 280rpx;
					height: 280rpx;
				}
			}

			.right {
				padding-top: 20rpx;
				padding-left: 20rpx;
				display: flex;
				font-size: 24rpx;
				flex-direction: column;
				justify-content: space-evenly;

				&-name {
					font-weight: 700;
				}

				&-price {
					font-weight: 700;
				}
			}
		}

	}

	.rank-page {
		height: 100vh;
		overflow-y: scroll;
	}

	.rank1 {
		background-color: #333d60;
	}
	.rank2 {
		background-color: #565968;
	}

	.container {
		padding-top: 80rpx;
		padding-bottom: 80rpx;
	}

	.top_title {
		font-size: 46rpx;
		text-align: center;
		font-weight: 700;
		color: #fff;
	}

	.top_btn {
		font-size: 24rpx;
		width: 180rpx;
		height: 45rpx;
		line-height: 45rpx;
		background-color: #fff;
		margin: 10rpx auto 30rpx;
		border-radius: 50rpx;
		// letter-spacing: 10rpx;
		text-align: center;
		color: rgb(89, 137, 185);
	}

	.rankleft-img {
		width: 59rpx;
		height: 93rpx;
	}

	.rankright-img {
		position: absolute;
		width: 59rpx;
		height: 93rpx;
		left: 300rpx;
	}

	.rankimg-box {
		position: absolute;
		left: 200rpx;
		top: 10rpx;
	}

	.icon-xiangyou1 {
		color: white;
		font-size: 24rpx;
	}

	.discribe {
		font-size: 22rpx;
		padding: 0 80rpx;
		color: #fff;
		text-align: center;
		margin-top: 40rpx;
		margin-bottom: 40rpx;
	}

	.phb-logo {
		position: relative;
	}
</style>